import re

# 在python的正则表达式里，默认额是贪婪模式，尽可能多的匹配
# 在贪婪模式后面添加 ? 可以将贪婪模式转换为非贪婪模式
m = re.search(r'm.*a', 'o3rjomjadas')
print(m.group())    # mjada

# 尽可能少的匹配
n = re.search(r'm.*?a', 'o3rjomjadas')
print(n.group())    # mja

print(re.match(r'aa(\d+)', 'aa2343ddd').group(0))   # aa2343
print(re.match(r'aa(\d+?)', 'aa2343ddd').group(0))   # aa2

print(re.match(r'aa(\d{2,})', 'aa2343ddd').group(0))   # aa2343
print(re.match(r'aa(\d{2,}?)', 'aa2343ddd').group(0))   # aa23

print(re.match(r'aa(\d+?)ddd', 'aa2343ddd').group(0))   # aa2343ddd
print(re.match(r'aa(\d+?)ddd', 'aa2343ddd').group(1))   # 2343

print(re.match(r'aa(\d+?).*', 'aa2343ddd').group(0))   # aa2343ddd
print(re.match(r'aa(\d+?).*', 'aa2343ddd').group(1))   # 2

src = 'https://sta-op.douyucdn.cn/nggsys/2021/03/16/91584811c69dc6473846ca03d83d5ccd.png'
print(re.search(r'https://.*\.png', src).group())
